package com.ruoyi.web.controller.moon;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.github.houbb.sensitive.word.core.SensitiveWordHelper;
import com.ruoyi.common.config.MySensitiveWordReplace;
import com.ruoyi.moon.domain.vo.CompanyReviewVO;
import org.junit.jupiter.api.Test;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.moon.domain.MoonCompany;
import com.ruoyi.moon.service.IMoonCompanyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 公司管理Controller
 * 
 * @author admin
 * @date 2024-11-05
 */
@RestController
@RequestMapping("/moon/company")
public class MoonCompanyController extends BaseController
{
    @Autowired
    private IMoonCompanyService moonCompanyService;

    /**
     * 查询公司管理列表
     */
    @PreAuthorize("@ss.hasPermi('moon:company:list')")
    @GetMapping("/list")
    public TableDataInfo list(MoonCompany moonCompany)
    {
        startPage();
        List<MoonCompany> list = moonCompanyService.selectMoonCompanyList(moonCompany);
        return getDataTable(list);
    }

    /**
     * 导出公司管理列表
     */
    @PreAuthorize("@ss.hasPermi('moon:company:export')")
    @Log(title = "公司管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MoonCompany moonCompany)
    {
        List<MoonCompany> list = moonCompanyService.selectMoonCompanyList(moonCompany);
        ExcelUtil<MoonCompany> util = new ExcelUtil<MoonCompany>(MoonCompany.class);
        util.exportExcel(response, list, "公司管理数据");
    }

    /**
     * 获取公司管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('moon:company:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(moonCompanyService.selectMoonCompanyById(id));
    }

    /**
     * 新增公司管理
     */
    @PreAuthorize("@ss.hasPermi('moon:company:add')")
    @Log(title = "公司管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MoonCompany moonCompany)
    {
        return toAjax(moonCompanyService.insertMoonCompany(moonCompany));
    }

    /**
     * 修改公司管理
     */
    @PreAuthorize("@ss.hasPermi('moon:company:edit')")
    @Log(title = "公司管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MoonCompany moonCompany)
    {
        return toAjax(moonCompanyService.updateMoonCompany(moonCompany));
    }

    /**
     * 删除公司管理
     */
    @PreAuthorize("@ss.hasPermi('moon:company:remove')")
    @Log(title = "公司管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(moonCompanyService.deleteMoonCompanyByIds(ids));
    }


    /**
     * 查询公司评论
     */
    @GetMapping("/reviewsList")
    public TableDataInfo CompanyReviews(CompanyReviewVO companyReviewVO)
    {
        startPage();
        List<CompanyReviewVO> list = moonCompanyService.selectCompanyReviews(companyReviewVO);
        return getDataTable(list);
    }
}
